import arcpy
import os.path
import os

dirname = os.path.dirname

mxd = arcpy.mapping.MapDocument("CURRENT")
mxdPath = mxd.filePath
outPath = dirname(mxdPath) + "/datas"

if not os.path.exists(outPath):
    os.makedirs(outPath)

filelist = [f for f in os.listdir(outPath) if f.endswith(".json")]
for f in filelist:
    os.remove(os.path.join(outPath, f))


layerList = arcpy.mapping.ListLayers(mxd)


for l in layerList:
    name = l.name
    outName = os.path.join(outPath, name + ".json")
    arcpy.FeaturesToJSON_conversion(
        name, outName)
